<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script>
        function f() {
            var a = document.getElementById("1");
            if (a.src.endsWith("1.png")){
                a.src="2.png";
            }
            else {
                a.src="1.png";
            }
        }
    </script>
</head>
<body>
    <input type="image" id= "1" src="1.png" onclick="f()">
    <p>点击图片开灯或关灯</p>
</body>
</html>